home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / edauxi.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  7KB  |  262 lines

  1. /*
  2.     GWAda Development Environment for 386/486 PCs   
  3.     Copyright (C) 1993, Arthur Vargas Lopes  & Michael Bliss Feldman
  4.                         vlopes@vortex.ufrgs.br mfeldman@seas.gwu.edu
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; version 2 of the License.    
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. /* edauxi.c */
  21. #include "externs.h"
  22.  
  23.  
  24. void AVL_MD_TOOLS()
  25. {
  26. }
  27.  
  28.  
  29.  
  30. void AVL_SHIFT_LEFT(char *s, short pos)
  31. {
  32.     int i, j;
  33.     if (pos < 1) return;
  34.     j = strlen(s);
  35.     for (i = pos - 1; i < j; ++i)
  36.         *(s+i) = *(s + i + 1);
  37. }
  38.  
  39.  
  40. void AVL_FULL_FN(char *s)
  41. {
  42.     sprintf(s,"%s%c%s",avl_dir_sources,'\\',avl_windows[avl_window].file_name);
  43. }
  44.  
  45.  
  46. void AVL_MAKE_FN(char *d, char *s)
  47. {
  48.     int i, j;
  49.     char fn[128];
  50.     for(i = strlen(s) - 1; i >= 0; --i)
  51.         if ((*(s + i) == ':') || (*(s + i) == '\\'))
  52.             break;
  53.     if (i < 0)
  54.         strcpy(d,s);
  55.     else 
  56.         strcpy(d,s+i+1);
  57. }
  58.         
  59.  
  60.  
  61. void AVL_FIX()
  62. {
  63.     unsigned int u, *u2;
  64.     int *i;
  65.     FILE *fp, *fopen();
  66.     char line[100];
  67.     AVL_LINE_PTR t;
  68.     AVL_EDIT_WINDOW_PTR w;
  69.     w = &avl_windows[avl_window];
  70.     w -> current_line = w -> head -> next;
  71.     w -> txt_pos = w -> line_no = 0;
  72.     if (w -> avl_win1 == NULL)  {
  73.         sprintf(line," Compiling %s ", w -> file_name);
  74.         w -> avl_win1 = AVL_MAKE_WINDOW(line,14,4,16,64,7,15);
  75.         _settextposition(3,1);
  76.         _outtext("Compiling line: ");
  77.         _settextposition(1,17);
  78.         }
  79. }
  80.  
  81. void AVL_GET_CDIR()
  82. {
  83.     avl_curr_directory[0] = '\0';
  84.     _getdcwd(0,avl_curr_directory,128);
  85. }
  86.  
  87. void AVL_DEFAULT_OPTIONS()
  88. {    
  89.     AVL_GET_CDIR();
  90.     strcpy(avl_dir_sources,avl_curr_directory);
  91.     sprintf(avl_dir_library,"%s",AVL_DEFAULT_LIB);
  92.     avl_heap = 32;
  93.     avl_monitor_on = '\0';
  94.     avl_pgm_stack = 4;
  95.     avl_task_stack = 2;
  96.     avl_scheduller = 0;
  97.     avl_trace_opts[0] = '\0';
  98.     avl_trace_opts[1] = '\0';
  99.     avl_trace_opts[2] = '\0';
  100.     avl_trace_opts[3] = '\0';
  101.     avl_trace_opts[4] = '\0';
  102.     avl_trace_opts[5] = '\0';
  103.     AVL_RESET_COLORS();
  104.     avl_tab_size = 4;
  105. }
  106.  
  107. void AVL_SAVE_OPTIONS()
  108. {
  109.     AVL_OPTIONS opt; 
  110.     int fp, n;
  111.     unlink(AVL_FN_OPTIONS);       
  112.     fp = open(AVL_FN_OPTIONS,O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
  113.     if (fp == -1)  {
  114.         AVL_ERROR("Can't save options. Check disk space.");
  115.         return;
  116.         }
  117.     strcpy(opt.sources,avl_dir_sources);
  118.     strcpy(opt.library,avl_dir_library);
  119.     opt.avl_monitor_on = avl_monitor_on;
  120.     opt.tabsize = avl_tab_size;
  121.     opt.avl_heap = avl_heap;
  122.     opt.avl_pgm_stack = avl_pgm_stack;
  123.     opt.avl_task_stack = avl_task_stack;
  124.     opt.avl_scheduller = avl_scheduller;
  125.     opt.avl_trace_opts[0] = avl_trace_opts[0];
  126.     opt.avl_trace_opts[1] = avl_trace_opts[1];
  127.     opt.avl_trace_opts[2] = avl_trace_opts[2];
  128.     opt.avl_trace_opts[3] = avl_trace_opts[3];
  129.     opt.avl_trace_opts[4] = avl_trace_opts[4];
  130.     opt.avl_trace_opts[5] = avl_trace_opts[5];
  131.     opt.avl_txt_color = avl_txt_color;
  132.     opt.avl_txt_bk_color = avl_txt_bk_color;
  133.     opt.avl_wnd_color = avl_wnd_color;
  134.     opt.avl_wnd_title = avl_wnd_title;
  135.     opt.avl_wnd_bk_color = avl_wnd_bk_color;
  136.     opt.avl_que_color = avl_que_color;
  137.     opt.avl_que_bk_color = avl_que_bk_color;
  138.     opt.avl_pro_color = avl_pro_color;
  139.     opt.avl_pro_bk_color = avl_pro_bk_color;
  140.     opt.avl_men_ready = avl_men_ready;
  141.     opt.avl_men_letter = avl_men_letter;
  142.     opt.avl_men_word = avl_men_word;
  143.     opt.avl_men_bk_color = avl_men_bk_color;
  144.     opt.avl_err_color = avl_err_color;
  145.     opt.avl_sta_color = avl_sta_color;
  146.     opt.avl_sta_bk_color = avl_sta_bk_color;
  147.     opt.avl_msg_color = avl_msg_color;
  148.     opt.avl_msg_bk_color = avl_msg_bk_color;
  149.  
  150.     n = write(fp,&opt,sizeof(AVL_OPTIONS));
  151.     if (n != sizeof(AVL_OPTIONS)) {
  152.         AVL_ERROR("Can't save options. Check disk space.");
  153.         close(fp);
  154.         unlink(AVL_FN_OPTIONS);       
  155.         }
  156.     else
  157.         close(fp);
  158. }
  159.  
  160. void AVL_READ_OPTIONS()
  161. {
  162.     AVL_OPTIONS opt; 
  163.     int fp, n;
  164.     fp = open(AVL_FN_OPTIONS,O_BINARY | O_RDWR, S_IREAD | S_IWRITE);
  165.     if (fp == -1)  {
  166.         AVL_DEFAULT_OPTIONS();
  167.         return;
  168.         }
  169.     n = read(fp,&opt,sizeof(AVL_OPTIONS));
  170.     if (n != sizeof(AVL_OPTIONS))  {
  171.         close(fp);
  172.         unlink(AVL_FN_OPTIONS);
  173.         AVL_DEFAULT_OPTIONS();
  174.         return;
  175.         }
  176.     avl_heap = opt.avl_heap;
  177.     avl_monitor_on = opt.avl_monitor_on;
  178.     avl_pgm_stack = opt.avl_pgm_stack;
  179.     avl_task_stack = opt.avl_task_stack;
  180.     avl_scheduller = opt.avl_scheduller;
  181.     avl_trace_opts[0] = opt.avl_trace_opts[0];
  182.     avl_trace_opts[1] = opt.avl_trace_opts[1];
  183.     avl_trace_opts[2] = opt.avl_trace_opts[2];
  184.     avl_trace_opts[3] = opt.avl_trace_opts[3];
  185.     avl_trace_opts[4] = opt.avl_trace_opts[4];
  186.     avl_trace_opts[5] = opt.avl_trace_opts[5];
  187.     avl_txt_color = opt.avl_txt_color;
  188.     avl_txt_bk_color = opt.avl_txt_bk_color;
  189.     avl_wnd_color = opt.avl_wnd_color;
  190.     avl_wnd_title = opt.avl_wnd_title;
  191.     avl_wnd_bk_color = opt.avl_wnd_bk_color;
  192.     avl_que_color = opt.avl_que_color;
  193.     avl_que_bk_color = opt.avl_que_bk_color;
  194.     avl_pro_color = opt.avl_pro_color;
  195.     avl_pro_bk_color = opt.avl_pro_bk_color;
  196.     avl_men_ready= opt.avl_men_ready;
  197.     avl_men_letter = opt.avl_men_letter;
  198.     avl_men_word = opt.avl_men_word;
  199.     avl_men_bk_color = opt.avl_men_bk_color;
  200.     avl_err_color = opt.avl_err_color;
  201.     avl_sta_color = opt.avl_sta_color;
  202.     avl_sta_bk_color = opt.avl_sta_bk_color;
  203.     avl_msg_color = opt.avl_msg_color;
  204.     avl_msg_bk_color = opt.avl_msg_bk_color;
  205.     strcpy(avl_dir_sources,opt.sources);
  206.     strcpy(avl_dir_library,opt.library);
  207.     avl_tab_size = opt.tabsize;
  208.     close(fp);
  209. }
  210.  
  211.  
  212.  
  213. AVL_LINE_PTR AVL_MAKE_LINE(char *l, int lno)
  214. {
  215.     AVL_LINE_PTR temp;
  216.     if (strlen(l) >= AVL_MAX_LINEL)  {
  217.         AVL_ERROR("Line too long. Truncated to 256 characters.");
  218.         *(l+256) = '\0';
  219.         }
  220.     temp = (AVL_LINE_PTR) calloc(1,sizeof(AVL_LINE_SIZE));
  221.     if (temp == NULL) {
  222.         AVL_ERROR("Out of memory...");
  223.         exit(1);
  224.         }
  225.     strcpy(temp -> line,l);
  226.     temp -> line_no = lno;
  227.     temp -> line_attrib = '\0';
  228.     temp -> previous =
  229.     temp -> next     = NULL;
  230.     return temp;
  231. }
  232.  
  233. void AVL_RENUMBER(AVL_LINE_PTR from, int c, int n)
  234. {
  235.     int count;
  236.     AVL_LINE_PTR temp;
  237.     count = c; 
  238.     temp = from;
  239.     while (temp -> line_no != 1)  {
  240.         temp -> line_no += count;
  241.         count += n;
  242.         temp = temp -> next;
  243.         }
  244. }
  245.  
  246. void AVL_LINE_INSERT(AVL_LINE_PTR this,AVL_LINE_PTR  *at)
  247. {
  248.     if (*at == NULL)  {  /*  First line  */
  249.         *at = this;
  250.         this -> previous =
  251.         this -> next     = this;
  252.         this -> line_no  = 1;
  253.         }    
  254.     else {
  255.         this -> previous = *at;
  256.         this -> next     = (*at) -> next;
  257.         ((*at) -> next) -> previous = this;
  258.         (*at) -> next = this;
  259.         AVL_RENUMBER(this, (*at) -> line_no + 1, 1);
  260.         }
  261. }
  262.